package com.zhuojy.equity.mall.admin.manager;

import cn.hutool.core.util.ObjUtil;
import com.zhuojy.equity.mall.admin.dal.dataobject.TUserDO;
import com.zhuojy.equity.mall.admin.dal.mapper.TUserMapper;
import com.zhuojy.equity.mall.admin.manager.bo.RegisterBO;
import com.zhuojy.equity.mall.admin.manager.struct.RegisterDoStruct;
import lombok.RequiredArgsConstructor;

import org.springframework.stereotype.Component;

/**
 * 用户表数据管理层
 */
@Component
@RequiredArgsConstructor
public class UserManager {

	private final TUserMapper userMapper;

	private final RegisterDoStruct registerDoStruct;

	/**
	 * 根据用户名查询用户信息
	 */
	public TUserDO queryUserByUsername(String username) {
		return userMapper.selectByUsername(username);
	}

	/**
	 * 用户注册
	 */
	public boolean registerUser(RegisterBO registerBO) {
		TUserDO tUserDO = registerDoStruct.toDO(registerBO);
		int rows = userMapper.insertUser(tUserDO);
		return rows == 1;
	}

}
